package com.imooc.controller;

import com.imooc.pojo.Stu;
import com.imooc.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 折戟沉沙铁未销
 * @version V1.0
 * @date 2020/1/28-2020
 * @Description: 这里用一句话描述这个类的作用
 */
@RestController
public class StuFooController {

    @Autowired
    private StuService stuService;

    /**
     * {@link Stu}  查询
     * @param id
     * @return
     */
    @RequestMapping("/getStu/{id}")
    public Stu getStu(@PathVariable("id") Integer id){
       return stuService.getStuInfo(id);
    }

    /**
     * {@link Stu} 保存
     * @return
     */
    @RequestMapping("/saveStu")
    public Object saveStu(){
        stuService.saveStu();
        return "ok";
    }

    /**
     * {@link Stu} 更新
     * @param id
     * @return
     */
    @RequestMapping("/updateStu/{id}")
    public Object updateStu(@PathVariable("id") Integer id){
        stuService.updateStu(id);
        return "ok";
    }

    /**
     * {@link Stu} 删除
     * @param id
     * @return
     */
    @RequestMapping("/deletStu/{id}")
    public Object deletStu(@PathVariable("id") Integer id){
        stuService.deleteStu(id);
        return "ok";
    }
}
